/**
* @file 秒杀
* @author 张超
* @created 2023/6/30 17:00
* @updated 2023/7/03 18:00
*/
<template>
	<view class="seckill">
		<view class="seckill-title"
			:style="{ background:'url('+rankingBgData+')',backgroundSize:'100% 100% !important'}">
			<view class="" @click="fanh">
				<u-icon name="arrow-left" size="40" color="#fff"></u-icon>
				<image src="@/static/shop/miaos1.png"></image>
			</view>
		</view>
		<!-- 内容 -->
		<view class="py-swiper">
			<scroll-view :scroll-y="true" class="scroll-Y" @scrolltolower="lower">
				<view class="swiper-son" v-for="(item,index) in list" :key="index">
					<image :src="item.goodsimage_text"></image>
					<view class="swiper-center">
						<view>{{item.goodsname}}</view>
						<view>{{item.desc}}</view>
						<!-- <u-line-progress active-color="#2979ff" :percent="70" :striped="true" :striped-active="true">
							43213人正在
						</u-line-progress> -->
						<view class="swiper-mouay">
							<text>{{item.sgoodsprice | xiaos}}</text>
							<text>金币+</text>
							<text>{{item.sgoodssalenum | xiaos}}</text>
							<text>积分</text>
						</view>
						<view>{{item.goodsprice | xiaos}}金币+{{item.goodssalenum | xiaos}}积分</view>
					</view>
					<view class="swiper-btn" @click="goSeckillDetail(item.id)">购买</view>
				</view>
			</scroll-view>
		</view>
	</view>
</template>

<script>
	import {
		goods_list
	} from '@/network/api.js'
	export default {
		data() {
			return {
				rankingBgData: '../../../static/shop/miaos.png',
				scrollHeight: 0,
				scrollIndexs: 0,
				scrollInto: "",
				list: [],
				page:1,
				// 购买中和即将购买切换
				qiang: false,
				loading: true, // 是否显示骨架屏组件
			}
		},
		onLoad() {
			this.listRe()
		},
		created() {
			let that = this;
			//获取可视化高度
			uni.getSystemInfo({
				success: function(res) {
					that.scrollHeight = res.windowHeight - uni.upx2px(56);
				},
			});
		},
		filters: {
			// 过滤小数点后面数据
			xiaos(num) {
				return Math.trunc(num)
			},
		},
		methods: {
			tabChange(index) {
				this.scrollIndexs = index;
				this.scrollInto = "tab" + index;
				console.log('触发')
			},
			swiperChange(e) {
				this.tabChange(e.detail.current);
			},
			lower: function(e) {
				this.page++
				this.listRe()
			},
			listRe(){
				let data = {
					is_killing:1,
					limit:10,
					page: this.page,
					pageSize: 5
				}
				goods_list(data).then(res => {
					this.list=res.data
				})
			},
			// 返回上一级
			fanh() {
				uni.navigateBack({
					delta: 1
				});
			},
			// 跳转到秒杀详情
			goSeckillDetail(id) {
				uni.navigateTo({
					url: '/pages/subpackage/shop/seckillDetail?id='+id
				})
			},
		}
	}
</script>

<style lang="scss">
	.seckill {
		background-color: #F3F3F3;

		.seckill-title {
			padding: 80rpx 30rpx;
			height: 400rpx;

			>view:nth-child(1) {
				display: flex;
				align-items: flex-start;

				>image {
					width: 304rpx;
					height: 80rpx;
					margin: 0 auto;
				}
			}
		}

		.py-swiper {
			margin: -150rpx 30rpx 0 30rpx;
			height: calc(100vh - 250rpx) !important;
			display: flex;

			.swiper-son {
				display: flex;
				height: 260rpx;
				margin-bottom: 20rpx;
				padding: 20rpx;
				border-radius: 10rpx;
				background-color: #fff;

				>image {
					width: 220rpx;
					height: 220rpx;
					margin-right: 20rpx;
					border-radius: 10rpx;
				}

				.swiper-center {
					width: 240rpx;

					>view:nth-child(1) {
						font-size: 30rpx;
						font-family: PingFang SC, PingFang SC-Bold;
						white-space: nowrap;
						overflow: hidden;
						text-overflow: ellipsis;
					}

					>view:nth-child(2) {
						font-size: 24rpx;
						font-family: PingFang SC, PingFang SC-Medium;
						color: #999999;
						white-space: nowrap;
						overflow: hidden;
						text-overflow: ellipsis;
					}

					>view:nth-child(3) {
						margin-top: 15rpx;
					}

					.swiper-mouay {
						margin-top: 20rpx;
						color: #E80000;

						>text:nth-child(odd) {
							font-size: 30rpx;
							font-family: PingFang SC, PingFang SC-Medium;
							font-weight: bold;
						}

						>text:nth-child(even) {
							font-size: 10rpx;
						}
					}

					>view:nth-child(5) {
						font-size: 11px;
						font-family: PingFang SC, PingFang SC-Medium;
						text-decoration: line-through;
						color: #999999;
					}
				}

				.swiper-btn {
					width: 136rpx;
					height: 68rpx;
					text-align: center;
					line-height: 68rpx;
					margin-left: auto;
					margin-top: 130rpx;
					color: #fff;
					background: linear-gradient(0deg, #ff4f4c 0%, #ff120e 100%);
					border-radius: 34rpx;
				}
			}
		}
	}
</style>